import { RouteRecordRaw } from 'vue-router'

/*
 * 静态路由
 */
const staticRoutes: Array<RouteRecordRaw> = [
    {
        // 管理员登录页
        path: '/login',
        name: 'login',
        component: () => import('/@/views/login/index.vue'),
        meta: {
            title: '登录'
        },
    },
    {
        // 后台找不到页面了-可能是路由未加载上
        path: '/:path(.*)*',
        redirect: (to) => {
            return { name: 'loading', query: { url: to.path, query: JSON.stringify(to.query) } }
        },
    }
]

/*
 * 后台基础静态路由
 */
const adminBaseRoute: RouteRecordRaw = {
    path: '/',
    name: '/',
    component: () => import('/@/layouts/index.vue'),
    redirect: 'loading',
    meta: {
        title: '管理后台'
    },
    children: [
        {
            path: 'loading',
            name: 'loading',
            component: () => import('/@/layouts/components/loading.vue'),
            meta: {
                title: '加载中'
            },
        },
        {
            path: 'iframe/:url',
            name: 'layoutIframe',
            component: () => import('/@/layouts/router-view/iframe.vue'),
            meta: {
                title: 'iframe',
            },
        }
    ],
}

staticRoutes.push(adminBaseRoute)

export { staticRoutes, adminBaseRoute }
